const http = require("http");
const fs  = require("fs");
const url = require("url");

http.createServer((req,res)=>{
	if(req.url != "/favicon.ico"){
		if(req.url.includes("@")){
			let url = req.url.replace("/@","http://localhost:3000");
			http.get(url,(response)=>{
				let str = ""
				response.on("data",(s)=>{
					str += s;
				})
				response.on("end",()=>{
					res.write(str);
					res.end();
				})
			})
		}else{
			fs.readFile(".."+url.parse(req.url).pathname,(err,data)=>{
				if(err){
					res.write("404");
				}else{
					res.write(data);
				}
				res.end();
			})
		}
	}
}).listen("3001")

 